package com.jeesite.modules.dataScreen.web;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson2.JSONObject;
import com.jeesite.modules.dataScreen.service.RailWayService;
import com.jeesite.modules.dataScreen.service.TianBaoService;
import com.jeesite.modules.dataScreen.web.vo.BasicPostalVO;
import com.jeesite.modules.dataScreen.web.vo.BasicRailwayVO;
import com.jeesite.modules.dataScreen.web.vo.MileagePopUpVo;
import com.jeesite.modules.dataScreen.web.vo.Result;
import com.jeesite.modules.dataScreen.web.vo.railway.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/railWay")
@Api(tags = "铁路")
public class RailWayApi {
    @Autowired
    private RailWayService railWayService;

    @Resource
    private TianBaoService tianBaoService;


    @ApiOperation("列车晚点滞留")
    @GetMapping("/trainDelay")
    public Result<JSONObject> getTrainDelay(@RequestParam(required = false) String status) {

        return Result.OK(railWayService.getTrainDelay(status));
    }

    @ApiOperation("滞留班次流程")
    @GetMapping("/retentionProcess")
    public Result<List<TrainDelayVO>> retentionProcess(@RequestParam(defaultValue = "重庆北站列车停运晚点") String name) {

        return Result.OK(railWayService.getRetentionProcess(name));
    }

//    @ApiOperation("铁路里程")
//    @GetMapping("/licheng")
//    public Result<Map<String, String>> licheng() {
//        return Result.OK(tianBaoService.getAll(CollUtil.toList("铁路运营里程", "高速铁路里程", "普速铁路里程", "铁路路网密度")));
//    }

    @ApiOperation("铁路客运")
    @GetMapping("/transportLk")
    public Result<TransportDataVo> lk() {
        return Result.OK(railWayService.getTransportDataVo("客运量", "旅客周转量"));
    }

    @ApiOperation("铁路货运")
    @GetMapping("/transportHy")
    public Result<TransportDataVo> hy() {
        return Result.OK(railWayService.getTransportDataVo("货运量", "货物周转量"));
    }

    @ApiOperation("铁路建设投资")
    @GetMapping("/railInvest")
    public Result<RailWayInvestVo> railInvest() {
        return Result.OK(railWayService.getRailInvest());
    }

    @ApiOperation("铁路里程")
    @GetMapping("/railWayMileage")
    public Result<RailWayMileageVo> railWayMileage() {
        return Result.OK(railWayService.railWayMileage());
    }

    @ApiOperation("轨道基础设施统计")
    @GetMapping("/railBasicService")
    public Result<JSONObject> railBasicService() {
        return Result.OK(railWayService.railBasicService());
    }

    @ApiOperation("轨道里程")
    @GetMapping("/trackMileage")
    public Result<JSONObject> trackMileage() {
        return Result.OK(railWayService.trackMileage());
    }

    @GetMapping("/basicRailway")
    @ApiOperation("铁路基础")
    public Result<BasicRailwayVO> basicRailway() {
        return Result.OK(railWayService.basicRailway());
    }

    @GetMapping("/mileagePopUp")
    @ApiOperation("铁路里程弹窗")
    public Result<MileagePopUpVo> mileagePopUp() {
        return Result.OK(railWayService.mileagePopUp());
    }

}
